const path = require('path');

exports.rules = [
    // 模块规则（配置 loader、解析器等选项）

    {
        test: /\.tsx?$/,
        include: [
            path.resolve(__dirname, "src")
        ],
        exclude: [
            path.resolve(__dirname, "node_modules")
        ],
        loader: "awesome-typescript-loader",
    },
    {
        test: /\.ts?$/,
        include: [
            // path.resolve(__dirname, "src")
            // "./src"
        ],
        exclude: [
            path.resolve(__dirname, "node_modules")
        ],
        loader: "awesome-typescript-loader",
    },
    {
        test: /\.(html)$/,
        use: {
            loader: 'html-loader',
            options: {
                // attrs: [':data-src']
            }
        }
    },
    {
        test: /\.js$/,
        include: [
            path.resolve(__dirname, "src")
        ],
        exclude: [
            path.resolve(__dirname, "node_modules")
        ],
        use: {
            loader: 'babel-loader',
            //   options: {
            //     presets: ['babel-preset-env']
            //   }
        }
    },
    {
        test: /\.jsx?$/,
        include: [
            path.resolve(__dirname, "src")
        ],
        exclude: [
            path.resolve(__dirname, "node_modules")
        ],
        loader: "babel-loader",
        options: {
            presets: ["babel-preset-react"]
        },
        // options for the loader
    },
    {
        test: /\.css$/,
        use: [
          { loader: "style-loader" },
          { loader: "css-loader" ,
            options:{
                url:true,
                minimize:true
            }
            }
        ]
    }
    // { // 太麻烦
    //     test: /\.scss$/,
    //     use: extractSass.extract({
    //         use: [{
    //             loader: "css-loader"
    //         }, {
    //             loader: "sass-loader",
    //             options: {
    //                 includePaths: ["absolute/path/a", "absolute/path/b"]
    //             }
    //         }],
    //         // 在开发环境使用 style-loader
    //         fallback: "style-loader"
    //     })
    // }
]

